{extend name="public/base"}

{block name="content"}
<div class="container-fluid">

    <div class="row">
        <div class="col-12">
            <div class="card-box">
                <div class="search-box">
                    <div class="col-sm-2"> 
                        <a href="#add-edit-modal" class="btn btn-custom waves-effect waves-light btn-md" data-animation="fadein" data-plugin="custommodal"
                                       data-overlaySpeed="200" data-overlayColor="#36404a" id="add-btn">+ 添加</a>
                    </div>
                    <div class="col-sm-10">
                        <form action="{:url('SysUser/index')}" method="get" class="form-inline form-inline-right">
                            <div class="form-group m-r-10">
                                <input type="text" class="form-control" id="exampleInputName2" name="username" value="{:isset($params.username) ? $params.username : ''}" placeholder="用户名">
                            </div>
                            <button type="submit" class="btn btn-custom waves-effect waves-light btn-md">
                                查询
                            </button>
                            <a href="{:url('SysUser/index')}" class="btn btn-custom waves-effect waves-light btn-md clear-search">清空</a>
                        </form>
                    </div>
                </div>
                <div class="table-rep-plugin">
                    <div class="table-responsive" data-pattern="priority-columns">
                        <table id="tech-companies-1" class="table  table-striped">
                            <thead>
                            <tr>
                                <th>用户ID</th>
                                <th data-priority="3">用户名</th>
                                <th data-priority="3">状态</th>
                                <th data-priority="1">最近登录时间</th>
                                <th data-priority="3">创建时间</th>
                                <th data-priority="6">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                {foreach $list as $item}
                                    <tr>
                                        <td>{$item.id}</td>
                                        <td>{$item.username}</td>
                                        <td><span class="{$item.status==1 ? 'status-on' : 'status-off'}">{$item.statusName}</span></td>
                                        <td>{$item.login_date}</td>
                                        <td>{$item.create_time}</td>
                                        <td class="actions">
                                            {if $item.user_type!=100}
                                            <a href="#add-edit-modal" class="on-default edit-row edit-btn" data-animation="fadein" data-plugin="custommodal"
                                            data-overlaySpeed="200" data-overlayColor="#36404a" data-url="{:url('SysUser/info',['id'=>$item.id])}">编辑</a>
                                            <a href="javacript:;" class="on-default remove-row delete-btn" data-url="{:url('SysUser/delete',['ids'=>$item.id])}">删除</a>
                                            {/if}
                                        </td>
                                    </tr>
                                {/foreach}
                            </tbody>
                        </table>
                        <div class="page-web">
                            {$page|raw}
                        </div>
                        
                    </div>

                </div>

            </div>
        </div>
    </div>
    <!-- end row -->

    <!-- Modal --> 
    <div id="add-edit-modal" class="modal-demo">
        <button type="button" class="close" onclick="Custombox.close();">
            <span>&times;</span><span class="sr-only">Close</span>
        </button>
        <h4 class="custom-modal-title"></h4>
        <div class="custom-modal-text">
            <form class="add-edit-form" method="post">
                <div class="form-group">
                    <label for="userName">用户名<span class="text-danger">*</span></label>
                    <input type="text" name="username" parsley-trigger="change" required
                           placeholder="请输入用户名" class="form-control" id="userName">
                </div>
            
                <div class="form-group">
                    <label for="pass1">密码<span class="text-danger">*</span></label>
                    <input id="pass1" type="password" name="password" placeholder="请输入密码" required
                           class="form-control">
                </div>

                <div class="form-group">
                    <label for="roleIds">所属角色</label>
                    <div class="checkbox role-checkbox checkbox-primary clearfix">
                        {foreach $roleList as $item}
                        <div class="checkbox-item">
                            <input id="checkbox{$item.id}" type="checkbox" name="roleIds[]" value="{$item.id}">
                            <label for="checkbox{$item.id}">{$item.role_name}</label>
                        </div>
                        {/foreach}
                    </div>
                </div>

                <div class="form-group">
                    <label for="status">状态<span class="text-danger">*</span></label>
                    <select class="form-control" name="status">
                        {foreach $statusList as $status}
                        <option value="{$status.code}">{$status.desc}</option>
                        {/foreach}
                    </select>
                </div>

                <div class="form-group text-center m-b-0">
                    <input type="hidden" name="id" >
                    <button class="btn btn-custom waves-effect waves-light" type="submit">确定</button>
                </div>

            </form>
        </div>
    </div>

</div> <!-- container -->

{/block}

{block name="script"}
<script>
    const addEditConfig = {
     'addUrl': "{:url('sysuser/add')}",
     'editUrl': "{:url('sysuser/edit')}"
    }
    const addData = {
     status: 1,
    }
 </script>
{/block}
